package com.zz.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zz.dao.ReadRoomsDao;
import com.zz.entity.ReadRooms;
import com.zz.service.ReadRoomsService;

@Service
public class ReadRoomsImpl implements ReadRoomsService {
	
	@Autowired
	ReadRoomsDao readDao;
	
	/**
	 * 查询所有资源室
	 */
	public Map<String, Object> GetAll() {
		Map<String, Object>map=new HashMap<String, Object>();
		map.put("code", 0);
		map.put("msg", "");
		map.put("data", readDao.findAll());
		map.put("count", null);
		return map;
	}

	/**
	 * 添加或者修改
	 */
	public Integer SaveAndFlushReadRooms(ReadRooms readrooms) {
		try {
			readDao.saveAndFlush(readrooms);
			return 1;
		} catch (Exception e) {
			return 0;
		}
	}

	/**
	 * 删除
	 */
	public Integer DelReadRooms(Integer Id) {
		try {
			readDao.deleteById(Id);
			return 1;
		} catch (Exception e) {
			return 0;
		}
	}

}
